﻿@model IPagination<Tariff>
@using BankCreditPortfolio.DAL.Entities
@using BankCreditPortfolio.DAL.Services
@using MvcContrib.Pagination
@using MvcContrib.UI.Grid
@using MvcContrib.UI.Pager

@{
    ViewBag.Title = "Tariffs";
}
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
<link href="@Url.Content("~/Content/Styles/customgrid.css")" rel="stylesheet" type="text/css" />
<link href="@Url.Content("~/Content/Admin/Styles/forms.css")" rel="stylesheet" type="text/css" />
@using (Html.BeginForm())
{
    <div>

    <h2>Tariffs</h2>

    @{
        if (Model.Count() > 0)
        {
            Html.Grid<Tariff>(Model).Columns(column =>
                {
                    //column.For(x => x.TariffId).Named("Tariff Id");
                    column.For(x => Html.ActionLink(x.Title, "Tariff", new { tariffId = x.TariffId })).Named("Title");
                    column.For(x => x.Description).Named("Description");
                    column.For(x => x.Currency.Title).Named("Currency");
                    column.For(x => x.CreditPercent).Named("Percent");
                    column.For(x => x.Fine).Named("Fine");
                    column.For(x => x.EarlyRepaymentFine).Named("Pre-term Repay Fine");
                    column.For(x => "Years: " + (x.Time.Year - 2000) + " Months: " + (x.Time.Month - 1)).Named("Term");
                    column.For(x => x.Used).Named("Is used");
                    column.For(x => (new OrderInfoService()).GetAllByTariff(x.TariffId) == null ?
                        Html.ActionLink("Edit...", "EditTariff", new { tariffId = x.TariffId }) : MvcHtmlString.Empty).Named("Edit");
                    column.For(x => (new OrderInfoService()).GetAllByTariff(x.TariffId) == null ?
                        Html.ActionLink("Delete...", "DeleteTariff", new { tariffId = x.TariffId }) : MvcHtmlString.Empty).Named("Delete");
                    column.For(x => Html.ActionLink("Change...", "ChangeTariffUsingStatatus", new { tariffId = x.TariffId})).Named("Using Status");
                }).Render();
             <br />
            @Html.Pager(Model).First("First").Last("Last").Next("Next").Previous("Previous")
        }
        else
        {
            <div>There is no tariffs.</div>
        }
    }

    </div>
}
